/*
 * Copyright 2006-2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.martinimix.beans.bind;

import com.bluemartini.dna.BusinessObject;

/**
 * Provides a Java beans field to Blue Martini <code>BusinesObject</code>
 * binder.
 * 
 * @author Scott Rossillo
 *
 */
public interface BusinessObjectBinder {

	/**
	 * Binds the given source object to a new business object instance.
	 * 
	 * @param bean the Java bean whose fields should be bound to 
	 * <code>BusinessObject</code> properties
	 * 
	 * @param businessObjectType the type of <code>BusinessObject</code>
	 * to be returned as defined by a Blue Martini data dictionary
	 * 
	 * @return a <code>BusinessObject</code> whose properties are set and bound
	 * to the values of the fields from the given <code>bean</code>
	 * 
	 * @throws BusinessObjectBindException if an unrecoverable binding error occurs
	 */
	public abstract BusinessObject bind(Object bean, String businessObjectType);
	
	/**
	 * Returns true if this business object binder supports binding
	 * from the given class.
	 * 
	 * @param clazz the <code>Class</code> to check for binding support
	 * 
	 * @return <code>true</code> if data binding is possible from the given
	 * <code>clazz</code>; <code>false</code> otherwise
	 */
	public abstract boolean supports(Class clazz);
	
}